﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09简单工厂模式
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    Console.Write("请输入数字A：");

                    double NumberA = double.Parse(Console.ReadLine());

                    Console.Write("请选择运算符号(+、-、*、/)：");

                    string strOperate = Console.ReadLine();

                    Console.Write("请输入数字B：");

                    double NumberB = double.Parse(Console.ReadLine());
                    Operation operation = SimpleFactory.CreateOperation(strOperate);
                    operation.NumberA = NumberA;
                    operation.NumberB = NumberB;
                    double result = operation.GetResult();
                    Console.WriteLine("运算结果是:{0}",result);
                }            
                catch (System.FormatException e)
                {
                    Console.WriteLine("只能输入数字,其他一概不行!");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.ToString());
                    Console.WriteLine(e.Source);
                }

            }



        }
    }
}
